package com.darwin.zuul_server.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.websocket.Session;

@Slf4j
@Component
public class authticationFilter extends ZuulFilter  {
    @Override
    public String filterType() {
        return "pre";
    }

    @Override
    public int filterOrder() {
        return 0;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() throws ZuulException {
        HttpServletRequest request = RequestContext.getCurrentContext().getRequest();

        String remoteHost = request.getRemoteHost();
        String requestURI = request.getRequestURI();
        String method = request.getMethod();
        log.info("remoteHost==>" + remoteHost + "requestURI==>" + requestURI + "method==>" + method);
        return "guojian";
    }
}
